<?php

/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Book
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.net/license/
 * @version    $Id: Controller.php 8369 2011-02-01 06:14:57Z john $
 * @author     John
 */

/**
 * @category   Application_Extensions
 * @package    Book
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.net/license/
 */
class Book_Widget_ListPopularBooksController extends Engine_Content_Widget_Abstract {

    public function indexAction() {
     
        $bookTb = Engine_Api::_()->getDbTable('books', 'book');
        $select = $bookTb->select();
        $select->group('book_id')
                ->having('MAX(view_count + comment_count + like_count)')
                ->order('book_id DESC')
                ->limit(2);

        $this->view->books = $bookTb->fetchAll($select);
    }

}
